package com.example.innovate.service.impl;

import com.example.innovate.domain.JobExamineDO;
import com.example.innovate.domain.JobExamineDOExample;
import com.example.innovate.domain.JobWantedDOExample;
import com.example.innovate.mapper.JobExamineDOMapper;
import com.example.innovate.mapper.JobWantedDOMapper;
import com.example.innovate.service.JobExamineService;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class JobExamineServiceImpl implements JobExamineService {
    @Autowired
    JobExamineDOMapper jobExamineDOMapper;

    @Override
    public JobExamineDO addInfo(JobExamineDO jobExamineDO) {
        jobExamineDOMapper.insertSelective(jobExamineDO);
        return jobExamineDO;
    }

    @Override
    public JobExamineDO findById(int id) {
        return jobExamineDOMapper.selectByPrimaryKey(id);
    }

    @Override
    public void deleteInfo(int id) {
        jobExamineDOMapper.deleteByPrimaryKey(id);
    }

    @Override
    public JobExamineDO updateInfo(JobExamineDO jobExamineDO) {
        jobExamineDOMapper.updateByPrimaryKeySelective(jobExamineDO);
        return jobExamineDO;
    }

    @Override
    public List<JobExamineDO> findAll(int wantedId, int pageNumber, int pageSize) {
        JobExamineDOExample jobExamineDOExample = new JobExamineDOExample();
        if (wantedId!=0){
            jobExamineDOExample.createCriteria().andExWantedIdEqualTo(wantedId);
        }
        PageHelper.startPage(pageNumber,pageSize);
        List<JobExamineDO> list = jobExamineDOMapper.selectByExample(jobExamineDOExample);
        return list;
    }
}
